<?php
/**
 * Sección indice de orquestamesta
 * @author Sahib J. Leo
 */
require '../../config.php';
require PATH . 'classes/ofj-orm/Director.php';
$css_arr = array(
  'css/orquesta/orquesta.css',
  'css/orquesta/sidebar_menu.css',
  'css/orquesta/directores/directores.css'
);
$js_arr = array();
require PATH . 'layout/header.php';
require PATH . 'orquesta/sidebar_menu.php';

$old_directores_lang = Lang::setSource('directores');
?>
<div id="musicians_secction">
  <h1 id="directores" class="bottom_bordered">
    <span><?php echo Lang::get('directors') ?></span>
    <?php echo Lang::get('of_orchestra') ?>
  </h1>
  <h2 id="actual_director">
    <div class="caret"></div>
    <?php echo Lang::get('actual_director') ?>
  </h2>
  <?php
  $directors = Director::instance()->find(array(
    'where' => '`nombre` IS NOT NULL',
    'order_by' => '`anio_inicio` DESC'
  ));
  $first = true;
  foreach($directors as $Director):
    ?>
    <div class="director_info bottom_bordered clearfix">
      <img class="director_img"
        style="width:<?php echo $first ? Director::IMG_WIDTH : 100 ?>px;height:<?php
          echo $first ? Director::IMG_HEIGHT : 150 ?>px;"
        src="<?php echo Director::getImageUrl($Director->id) ?>" />
      <div class="bio <?php if($first) echo 'first' ?>">
        <h3>
          <?php if(!$first): ?>
          <div class="caret"></div>
          <?php endif ?>
          <?php echo htmlentities($Director->nombre. ' '. $Director->apellidos
          , ENT_QUOTES, 'utf-8') ?>
        </h3>
        <strong>
          <?php
          if($first):
            echo Lang::get('since'), ' ', $Director->getPeriodo();
          else:
            if(LANG == 'en'):
              echo $Director->getPeriodo(), ' ', Lang::get('period');
            else:
              echo Lang::get('period'), ' ', $Director->getPeriodo();
            endif;
          endif;
          ?>
        </strong>
        <?php
        // OJO: TinyMCE a veces hace wrap del pagebreak en tags <p>
        $bio = preg_split('@(<p>)?<!-- pagebreak -->(</p>)?@', $Director->get('bio'));
        echo $bio[0];
        ?>
        <a class="readmore" href="orquesta/directores/detalle.php?id=<?php echo $Director->id ?>">
          <img src="img/home/see-details.gif" align="bottom" />
          <?php echo Lang::get('read_more') ?>
        </a>
      </div>
    </div><!-- .director_info -->
    <?php
      $first = false;
    endforeach;
    ?>
</div>
<?php
Lang::setSource($old_directores_lang);
require PATH . 'layout/footer.php';